//let baseUrl = '172.20.10.5'
import { getCookies } from '@/utils/cookies'
const baseUrl = 'http://localhost:8080/spring-boot'
//const baseUrl = 'http://10.96.116.33:8080/spring-boot'
export function get(url:string,params:any){
  return new Promise((reslove,rej) => 
  {
     wx.request({
      url: baseUrl + url,
      data:{
        ...params
      },
      header: {
        'content-type': 'application/json', // 默认值
        'token': getCookies('token')
      },
      method:'GET',
      success(res) {
        reslove(res.data)
      },
      fail(err) {
        rej('报错啦')
      }
    })
  })
}
export function post(url:string,params:any){
  return new Promise((reslove,rej) => 
  {
     wx.request({
      url: baseUrl + url,
      data:{
        ...params
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'Authorization': 'application/x-www-form-urlencoded',
        'token': getCookies('token')
      },
      method:'POST',
      success(res) {
        reslove(res.data)
      },
      fail(err) {
        rej('报错啦')
      }
    })
  })
}